package edu.ynu.se.xiecheng.achitectureclass.dto;

import edu.ynu.se.xiecheng.achitectureclass.entity.Greenhouse;
import lombok.Getter;
import lombok.Setter;

import java.util.Set;
import java.util.stream.Collectors;

@Getter
@Setter
public class GreenhouseObject {

    private String greenhouseName;
    private String greenhouseArea;
    private String greenhouseLocation;
    private String cameraToken;
    private Long cameraTokenExpireTime;
    private Set<DeviceObject> devices;

    public GreenhouseObject(Greenhouse greenhouse) {
        this.greenhouseName = greenhouse.getGreenhouseName();
        this.greenhouseArea = greenhouse.getGreenhouseArea();
        this.greenhouseLocation = greenhouse.getGreenhouseLocation();
        this.cameraToken = greenhouse.getCameraToken();
        this.cameraTokenExpireTime = greenhouse.getCameraTokenExpireTime();
        this.devices = greenhouse.getDevices().stream().map(DeviceObject::new).collect(Collectors.toSet());
    }

}
